/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((module) => {

module.exports = require("@nestjs/core");

/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AmqpModule = void 0;
const common_1 = __webpack_require__(3);
const amqp_service_1 = __webpack_require__(4);
const amqp_client_1 = __webpack_require__(5);
const cache_1 = __webpack_require__(11);
const configure_1 = __webpack_require__(16);
const typeorm_1 = __webpack_require__(26);
const device_repository_module_1 = __webpack_require__(30);
let AmqpModule = class AmqpModule {
};
exports.AmqpModule = AmqpModule;
exports.AmqpModule = AmqpModule = __decorate([
    (0, common_1.Module)({
        imports: [
            configure_1.ConfigureModule.forRoot(),
            cache_1.CacheModule,
            typeorm_1.TypeOrmModule.forRootAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        ...config.get('db')
                    };
                },
            }),
            amqp_client_1.AmqpClientModule.forRootAsync({
                inject: [configure_1.ConfigureService],
                useFactory: async (config) => {
                    const conf = config.get('alicloud');
                    return {
                        uid: conf.uid,
                        accessKeyId: conf.accessKeyId,
                        iotInstanceId: conf.iotInstanceId,
                        accessKeySecret: conf.accessKeySecret,
                        regionId: conf.regionId,
                        consumerGroupId: conf.consumerGroupId,
                    };
                }
            }),
            device_repository_module_1.DeviceRepositoryModule,
        ],
        providers: [amqp_service_1.AmqpService],
    })
], AmqpModule);


/***/ }),
/* 3 */
/***/ ((module) => {

module.exports = require("@nestjs/common");

/***/ }),
/* 4 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a, _b, _c, _d;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AmqpService = void 0;
const amqp_client_1 = __webpack_require__(5);
const cache_1 = __webpack_require__(11);
const configure_1 = __webpack_require__(16);
const device_repository_service_1 = __webpack_require__(25);
const common_1 = __webpack_require__(3);
let AmqpService = class AmqpService {
    constructor(device, amqpClient, config, cache) {
        this.device = device;
        this.amqpClient = amqpClient;
        this.config = config;
        this.cache = cache;
        this.DEVICE_MSG_OF_IOT_KEY = this.config.get('DEVICE_MSG_OF_IOT_KEY');
        this.DEVICE_MSG_OF_REPORT_KEY = this.config.get('DEVICE_MSG_OF_REPORT_KEY');
    }
    onModuleInit() {
        this.amqpClient.on('message', (context) => {
            context.delivery.accept();
            var msg = context.message;
            console.log(msg.application_properties.topic);
            console.log(msg.body.content.toString());
            const time = Math.floor(Date.now() / 1000);
            if (msg.application_properties.topic.indexOf('/as/mqtt/status') == 0) {
                try {
                    const data = JSON.parse(msg.body.content.toString());
                    const deviceId = Number(data.deviceName);
                    if (data.status == 'online') {
                        this.device.update({ id: deviceId }, { connectStatus: 1 });
                    }
                    else if (data.status == 'offline') {
                        this.device.update({ id: deviceId }, { connectStatus: 0, offlineTime: time });
                    }
                }
                catch (error) {
                }
            }
            else {
                try {
                    this.cache.client.lpush(this.DEVICE_MSG_OF_REPORT_KEY, JSON.stringify({ time: time, topic: msg.application_properties.topic, data: msg.body.content.toString() }));
                }
                catch (error) {
                }
            }
            context.delivery.accept();
        });
        this.amqpClient.connect();
    }
};
exports.AmqpService = AmqpService;
exports.AmqpService = AmqpService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof device_repository_service_1.DeviceRepositoryService !== "undefined" && device_repository_service_1.DeviceRepositoryService) === "function" ? _a : Object, typeof (_b = typeof amqp_client_1.AmqpClientService !== "undefined" && amqp_client_1.AmqpClientService) === "function" ? _b : Object, typeof (_c = typeof configure_1.ConfigureService !== "undefined" && configure_1.ConfigureService) === "function" ? _c : Object, typeof (_d = typeof cache_1.CacheService !== "undefined" && cache_1.CacheService) === "function" ? _d : Object])
], AmqpService);


/***/ }),
/* 5 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(6), exports);
__exportStar(__webpack_require__(7), exports);


/***/ }),
/* 6 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AmqpClientModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AmqpClientModule = void 0;
const common_1 = __webpack_require__(3);
const amqp_client_service_1 = __webpack_require__(7);
let AmqpClientModule = AmqpClientModule_1 = class AmqpClientModule {
    static forRootAsync(connections) {
        return {
            module: AmqpClientModule_1,
            imports: connections.imports || [],
            providers: [
                {
                    provide: 'AMQP_CONNECT_OPTIONS',
                    useFactory: connections.useFactory,
                    inject: connections.inject || [],
                },
                amqp_client_service_1.AmqpClientService,
            ],
            exports: [amqp_client_service_1.AmqpClientService],
        };
    }
};
exports.AmqpClientModule = AmqpClientModule;
exports.AmqpClientModule = AmqpClientModule = AmqpClientModule_1 = __decorate([
    (0, common_1.Module)({
        providers: [amqp_client_service_1.AmqpClientService],
        exports: [amqp_client_service_1.AmqpClientService],
    })
], AmqpClientModule);


/***/ }),
/* 7 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AmqpClientService = void 0;
const common_1 = __webpack_require__(3);
const container = __webpack_require__(8);
const crypto_1 = __webpack_require__(9);
const ConnectOptions_1 = __webpack_require__(10);
let AmqpClientService = class AmqpClientService {
    constructor(options) {
        this.options = options;
        this.eventList = [];
    }
    hmacSha1(key, context) {
        return Buffer.from((0, crypto_1.createHmac)('sha1', key).update(context).digest())
            .toString('base64');
    }
    connect() {
        const timestamp = Date.now() / 1000;
        let username = `${(0, crypto_1.randomUUID)()}|authMode=aksign,signMethod=hmacsha1,timestamp=${timestamp},authId=${this.options.accessKeyId}`;
        if (this.options.iotInstanceId) {
            username += (`,iotInstanceId=${this.options.iotInstanceId}`);
        }
        username += (`,consumerGroupId=${this.options.consumerGroupId}|`);
        const password = Buffer.from((0, crypto_1.createHmac)('sha1', this.options.accessKeySecret).update('authId=' + this.options.accessKeyId + '&timestamp=' + timestamp).digest()).toString('base64');
        const params = {
            'host': `${this.options.uid}.iot-amqp.${this.options.regionId}.aliyuncs.com`,
            'port': 5671,
            'transport': 'tls',
            'reconnect': true,
            'idle_time_out': 60000,
            'username': username,
            'password': password,
        };
        this._connection = container.connect(params);
        while (true) {
            const e = this.eventList.pop();
            if (e) {
                this._connection.on(e[0], e[1]);
            }
            else {
                break;
            }
        }
        this._connection.open_receiver();
    }
    get connection() {
        return this._connection;
    }
    on(event, callback) {
        if (!this._connection) {
            this.eventList.push([event, callback]);
        }
        else {
            this._connection.on(event, callback);
        }
    }
};
exports.AmqpClientService = AmqpClientService;
exports.AmqpClientService = AmqpClientService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)('AMQP_CONNECT_OPTIONS')),
    __metadata("design:paramtypes", [typeof (_a = typeof ConnectOptions_1.ConnectOptions !== "undefined" && ConnectOptions_1.ConnectOptions) === "function" ? _a : Object])
], AmqpClientService);


/***/ }),
/* 8 */
/***/ ((module) => {

module.exports = require("rhea");

/***/ }),
/* 9 */
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),
/* 10 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));


/***/ }),
/* 11 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(12), exports);
__exportStar(__webpack_require__(14), exports);


/***/ }),
/* 12 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheModule = void 0;
const common_1 = __webpack_require__(3);
const cache_manager_1 = __webpack_require__(13);
const cache_service_1 = __webpack_require__(14);
const configure_1 = __webpack_require__(16);
const cache_manager_ioredis_yet_1 = __webpack_require__(24);
let CacheModule = class CacheModule {
};
exports.CacheModule = CacheModule;
exports.CacheModule = CacheModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [cache_manager_1.CacheModule.registerAsync({
                imports: [configure_1.ConfigureModule],
                inject: [configure_1.ConfigureService],
                useFactory: (config) => {
                    return {
                        store: cache_manager_ioredis_yet_1.redisStore,
                        ...config.get('cache')
                    };
                }
            })],
        providers: [cache_service_1.CacheService],
        exports: [cache_service_1.CacheService],
    })
], CacheModule);


/***/ }),
/* 13 */
/***/ ((module) => {

module.exports = require("@nestjs/cache-manager");

/***/ }),
/* 14 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CacheService = void 0;
const cache_manager_1 = __webpack_require__(13);
const common_1 = __webpack_require__(3);
const cache_manager_2 = __webpack_require__(15);
let CacheService = class CacheService {
    constructor(cacheManager) {
        this.cacheManager = cacheManager;
        this.Client = this.cacheManager.store.client;
    }
    get client() {
        return this.Client;
    }
    async set(...args) {
        let res;
        let argsLen = args.length;
        if (argsLen == 2) {
            res = await this.Client.set(args[0], args[1]);
        }
        else if (argsLen == 3) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2]);
        }
        else if (argsLen == 4) {
            res = await this.Client.set(args[0], args[1], 'EX', args[2], 'NX');
        }
        return res === 'OK';
    }
    pop(key) {
        return this.Client.rpop(key);
    }
    get(key) {
        return this.Client.get(key);
    }
    del(...keys) {
        return this.Client.del(...keys);
    }
    blpop(key, timeout) {
        return this.Client.blpop(key, timeout);
    }
    async blockLock(key, timeout) {
        const len = await this.Client.llen(key);
        if (len == 0) {
            const rs = await this.set(key + ':nx', '1', timeout + 3, 'NX');
            if (rs) {
                return true;
            }
        }
        const res = await this.blpop(key, timeout);
        return res ? true : false;
    }
    async unBlockLock(key) {
        this.Client.lpush(key, '1');
    }
    hmset(key, data) {
        this.Client.hmset(key, data);
    }
    hgetall(key) {
        return this.Client.hgetall(key);
    }
};
exports.CacheService = CacheService;
exports.CacheService = CacheService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
    __metadata("design:paramtypes", [typeof (_a = typeof cache_manager_2.Cache !== "undefined" && cache_manager_2.Cache) === "function" ? _a : Object])
], CacheService);


/***/ }),
/* 15 */
/***/ ((module) => {

module.exports = require("cache-manager");

/***/ }),
/* 16 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(17), exports);
__exportStar(__webpack_require__(18), exports);


/***/ }),
/* 17 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ConfigureModule_1;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureModule = void 0;
const common_1 = __webpack_require__(3);
const configure_service_1 = __webpack_require__(18);
const config_1 = __webpack_require__(19);
const config_2 = __webpack_require__(20);
const fs = __webpack_require__(21);
const path = __webpack_require__(22);
const yaml = __webpack_require__(23);
let ConfigureModule = ConfigureModule_1 = class ConfigureModule {
    static async forRoot(load = null) {
        const loads = [config_2.default];
        if (load) {
            loads.push(load);
        }
        try {
            const folderPath = 'config';
            const files = await fs.promises.readdir(folderPath);
            for (const file of files) {
                const filePath = path.join(folderPath, file);
                loads.push(() => {
                    return yaml.load(fs.readFileSync(filePath, 'utf8'));
                });
            }
        }
        catch (err) {
            console.error(err);
        }
        const options = {
            isGlobal: true,
            expandVariables: true,
            load: loads,
            envFilePath: [`.env.${process.env.APP_NAME}`, '.env', `.env.${process.env.NODE_ENV}`]
        };
        return {
            global: true,
            module: ConfigureModule_1,
            providers: [configure_service_1.ConfigureService],
            exports: [configure_service_1.ConfigureService],
            imports: [
                config_1.ConfigModule.forRoot(options)
            ]
        };
    }
};
exports.ConfigureModule = ConfigureModule;
exports.ConfigureModule = ConfigureModule = ConfigureModule_1 = __decorate([
    (0, common_1.Global)()
], ConfigureModule);


/***/ }),
/* 18 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ConfigureService = void 0;
const common_1 = __webpack_require__(3);
const config_1 = __webpack_require__(19);
let ConfigureService = class ConfigureService {
    constructor(configService) {
        this.configService = configService;
    }
    get(propertyPath) {
        return this.configService.get(propertyPath);
    }
};
exports.ConfigureService = ConfigureService;
exports.ConfigureService = ConfigureService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [typeof (_a = typeof config_1.ConfigService !== "undefined" && config_1.ConfigService) === "function" ? _a : Object])
], ConfigureService);


/***/ }),
/* 19 */
/***/ ((module) => {

module.exports = require("@nestjs/config");

/***/ }),
/* 20 */
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = () => {
    return {
        wxAccessTokenKey: 'wx:access:token',
        startChargeResKey: 'scr:',
        endChargeResKey: 'ecr:',
        userChargingOrderKey: 'ucing:',
        devicePortChargingKeyReg: 'd:?:p:?',
        deviceIdPortToOrderIdReg: '?:?:oid',
        PstartChargeResKey: 'p:scr:',
        PendChargeResKey: 'p:ecr:',
        PdeviceChargingOrderKey: 'p:dcing:',
        aliToDeviceTopicReg: '/?/?/user/alternating/get',
        deviceMsgListKeys: {
            chargeInfo: 'charge:info:list'
        }
    };
};


/***/ }),
/* 21 */
/***/ ((module) => {

module.exports = require("fs");

/***/ }),
/* 22 */
/***/ ((module) => {

module.exports = require("path");

/***/ }),
/* 23 */
/***/ ((module) => {

module.exports = require("js-yaml");

/***/ }),
/* 24 */
/***/ ((module) => {

module.exports = require("cache-manager-ioredis-yet");

/***/ }),
/* 25 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryService = void 0;
const common_1 = __webpack_require__(3);
const typeorm_1 = __webpack_require__(26);
const typeorm_2 = __webpack_require__(27);
const base_service_1 = __webpack_require__(28);
const Device_1 = __webpack_require__(29);
let DeviceRepositoryService = class DeviceRepositoryService extends base_service_1.BaseService {
    constructor(repository) {
        super();
        this.repository = repository;
        this.primaryKey = 'id';
    }
};
exports.DeviceRepositoryService = DeviceRepositoryService;
exports.DeviceRepositoryService = DeviceRepositoryService = __decorate([
    (0, common_1.Injectable)(),
    __param(0, (0, typeorm_1.InjectRepository)(Device_1.Device)),
    __metadata("design:paramtypes", [typeof (_a = typeof typeorm_2.Repository !== "undefined" && typeorm_2.Repository) === "function" ? _a : Object])
], DeviceRepositoryService);


/***/ }),
/* 26 */
/***/ ((module) => {

module.exports = require("@nestjs/typeorm");

/***/ }),
/* 27 */
/***/ ((module) => {

module.exports = require("typeorm");

/***/ }),
/* 28 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaseService = void 0;
const common_1 = __webpack_require__(3);
let BaseService = class BaseService {
    getRepository() {
        return this.repository;
    }
    get aliasToOriginalFields() {
        if (!this.aliasToOriginalFieldsMap) {
            this.aliasToOriginalFieldsMap = {};
            this.repository.metadata.ownColumns.forEach(column => {
                this.aliasToOriginalFieldsMap[column.propertyName] = column.databaseName;
            });
        }
        return this.aliasToOriginalFieldsMap;
    }
    get metadata() {
        return this.repository.metadata;
    }
    get tableName() {
        return this.repository.metadata.tableName;
    }
    createQueryBuilder() {
        return this.repository.createQueryBuilder();
    }
    aliasToFields(fields) {
        const aliasToOriginalFieldsMap = this.aliasToOriginalFields;
        return fields.map((field) => `\`${aliasToOriginalFieldsMap[field]}\` as \`${field}\``).join(',');
    }
    createQueryRunner() {
        return this.dataSource.createQueryRunner();
    }
    query(query, parameters) {
        return this.repository.query(query, parameters);
    }
    async count(where) {
        let total = await this.repository.count({
            where: where
        });
        return total;
    }
    async pagination(pageNo, pageSize, where, select, order) {
        pageSize = Number(pageSize);
        return this.find(where, select, (Number(pageNo) - 1) * pageSize, pageSize, order);
    }
    findOne(where, select, order) {
        return this.repository.findOne({
            select: select,
            where: where,
            order: order
        });
    }
    find(where, select, skip, take, order) {
        let options = {};
        if (where) {
            options.where = where;
        }
        if (select) {
            options.select = select;
        }
        if (skip) {
            options.skip = skip;
        }
        if (take) {
            options.take = take;
        }
        if (order) {
            options.order = order;
        }
        return this.repository.find(options);
    }
    async value(where, field) {
        const res = await this.findOne(where, [field]);
        return res ? res[field] : undefined;
    }
    async isExistsByWhere(where) {
        let res = await this.findOne(where, [this.primaryKey]);
        return res ? true : false;
    }
    async save(data, options) {
        return this.repository.save(data, options);
    }
    async saveMany(data, options) {
        return this.repository.save(data, options);
    }
    async insert(data) {
        let result = null;
        try {
            let res = await this.repository.insert(data);
            if (res) {
                let generatedMaps = res.generatedMaps;
                if (generatedMaps && generatedMaps.length > 0) {
                    result = {
                        affectedRows: generatedMaps.length,
                        rows: generatedMaps
                    };
                }
            }
        }
        catch (error) {
            console.log(error);
        }
        return result;
    }
    async update(criteria, partialEntity) {
        try {
            let res = await this.repository.update(criteria, partialEntity);
            return res.affected;
        }
        catch (error) {
            console.log(error);
        }
        return 0;
    }
    async delete(criteria) {
        try {
            let res = await this.repository.delete(criteria);
            return res.affected;
        }
        catch (error) {
        }
        return 0;
    }
};
exports.BaseService = BaseService;
exports.BaseService = BaseService = __decorate([
    (0, common_1.Injectable)()
], BaseService);


/***/ }),
/* 29 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Device = void 0;
const typeorm_1 = __webpack_require__(27);
let Device = class Device {
};
exports.Device = Device;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", name: "id", unsigned: true }),
    __metadata("design:type", Number)
], Device.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "name", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "device_type_id",
        comment: "类型",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "deviceTypeId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "total_water_usage",
        comment: "总用水量",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "totalWaterUsage", void 0);
__decorate([
    (0, typeorm_1.Column)("json", { name: "port_data", nullable: true, comment: "端口数据" }),
    __metadata("design:type", Object)
], Device.prototype, "portData", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "connect_status",
        comment: "链接状态1：是，0：否",
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "connectStatus", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "online_time",
        comment: "上线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "onlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "offline_time",
        comment: "离线时间",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "offlineTime", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "at_ali",
        comment: "是否已经注册到阿里云"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "atAli", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "ali_id", comment: "阿里云的设备id", length: 32 }),
    __metadata("design:type", String)
], Device.prototype, "aliId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", {
        name: "ali_secret",
        comment: "阿里云的设备Secret",
        length: 32,
    }),
    __metadata("design:type", String)
], Device.prototype, "aliSecret", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "merchant_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "merchantId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "station_id",
        comment: "站点id",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "stationId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "user_id", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)("char", { name: "sim", comment: "物联网卡", length: 20 }),
    __metadata("design:type", String)
], Device.prototype, "sim", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "hardware", comment: "硬件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "hardware", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "software", comment: "软件", length: 30 }),
    __metadata("design:type", String)
], Device.prototype, "software", void 0);
__decorate([
    (0, typeorm_1.Column)("tinyint", {
        name: "signal",
        comment: "信号强度",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "signal", void 0);
__decorate([
    (0, typeorm_1.Column)("varchar", { name: "remark", length: 100 }),
    __metadata("design:type", String)
], Device.prototype, "remark", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", {
        name: "is_private",
        comment: "1：私人的"
    }),
    __metadata("design:type", Boolean)
], Device.prototype, "isPrivate", void 0);
__decorate([
    (0, typeorm_1.Column)("boolean", { name: "enable" }),
    __metadata("design:type", Boolean)
], Device.prototype, "enable", void 0);
__decorate([
    (0, typeorm_1.Column)("int", {
        name: "creator_id",
        comment: "创建人",
        unsigned: true,
        default: () => "'0'",
    }),
    __metadata("design:type", Number)
], Device.prototype, "creatorId", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "create_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "createTime", void 0);
__decorate([
    (0, typeorm_1.Column)("int", { name: "update_time", unsigned: true, default: () => "'0'" }),
    __metadata("design:type", Number)
], Device.prototype, "updateTime", void 0);
exports.Device = Device = __decorate([
    (0, typeorm_1.Entity)("device", { schema: "charge" })
], Device);


/***/ }),
/* 30 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DeviceRepositoryModule = void 0;
const common_1 = __webpack_require__(3);
const device_repository_service_1 = __webpack_require__(25);
const typeorm_1 = __webpack_require__(26);
const Device_1 = __webpack_require__(29);
let DeviceRepositoryModule = class DeviceRepositoryModule {
};
exports.DeviceRepositoryModule = DeviceRepositoryModule;
exports.DeviceRepositoryModule = DeviceRepositoryModule = __decorate([
    (0, common_1.Module)({
        imports: [typeorm_1.TypeOrmModule.forFeature([Device_1.Device])],
        providers: [device_repository_service_1.DeviceRepositoryService],
        exports: [device_repository_service_1.DeviceRepositoryService]
    })
], DeviceRepositoryModule);


/***/ })
/******/ 	]);
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
var exports = __webpack_exports__;

Object.defineProperty(exports, "__esModule", ({ value: true }));
const core_1 = __webpack_require__(1);
const amqp_module_1 = __webpack_require__(2);
async function bootstrap() {
    await core_1.NestFactory.createApplicationContext(amqp_module_1.AmqpModule);
    console.log(`------------ ${process.env.APP_NAME} start---------------`);
    const date = new Date();
    console.log(date.toLocaleDateString() + ' ' + date.toLocaleTimeString());
}
bootstrap();

})();

/******/ })()
;